package ck.android.englishschool.util;

import java.util.ArrayList;
import java.util.HashMap;

import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;

import ck.android.englishschool.vo.MemberVO;
import ck.android.englishschool.vo.WordDetailVO;


public class ParameterUtil {
	
	public static boolean isNull(String str){
		return (str == null || str.equals(""))?true:false;
	}
	
	//REQ001 - 로그인
	public static ArrayList<NameValuePair> getLoginPostParams(MemberVO memberVo) {	
		ArrayList<NameValuePair> paramsArray = new ArrayList<NameValuePair>();
		
		paramsArray.add(new BasicNameValuePair(Const.PARAM_TARGET, Const.REQ001));
		paramsArray.add(new BasicNameValuePair(MemberVO.USERID, memberVo.getUserId()));
		paramsArray.add(new BasicNameValuePair(MemberVO.USERPASS, memberVo.getUserPass()));
		
		return paramsArray;
	}
	//REQ002 - 회원가입
	public static ArrayList<NameValuePair> getRegistPostParams(MemberVO memberVo) {	
		ArrayList<NameValuePair> paramsArray = new ArrayList<NameValuePair>();
		
		paramsArray.add(new BasicNameValuePair(Const.PARAM_TARGET, Const.REQ002));
		paramsArray.add(new BasicNameValuePair(MemberVO.USERID, memberVo.getUserId()));
		paramsArray.add(new BasicNameValuePair(MemberVO.USERPASS, memberVo.getUserPass()));
		
		return paramsArray;
	}
	//REQ003 - WordList 가져오기
	public static ArrayList<NameValuePair> getWordListParams(HashMap<String, String> searchMap) {	
		ArrayList<NameValuePair> paramsArray = new ArrayList<NameValuePair>();
		
		paramsArray.add(new BasicNameValuePair(Const.PARAM_TARGET, Const.REQ003));
		
		if(!isNull(searchMap.get("targetPage").toString())) {
			paramsArray.add(new BasicNameValuePair(Const.TARGET_PAGE
					, searchMap.get("targetPage").toString()));
		}
		/*if(!isNull(searchMap.get("sDate").toString())) {
			paramsArray.add(new BasicNameValuePair(Const.SEARCH_SDATE
					, searchMap.get("sDate").toString()));
		}
		if(!isNull(searchMap.get("eDate").toString())) {
			paramsArray.add(new BasicNameValuePair(Const.SEARCH_EDATE
					, searchMap.get("eDate").toString()));
		}*/
		
		return paramsArray;
	}
	//REQ004 - WordDetail 가져오기
	public static ArrayList<NameValuePair> getWordDetailParams(WordDetailVO wordDetailVo){
		ArrayList<NameValuePair> paramsArray = new ArrayList<NameValuePair>();
		
		paramsArray.add(new BasicNameValuePair(Const.PARAM_TARGET, Const.REQ004));
		
		if(!isNull(wordDetailVo.getTitle())){
			paramsArray.add(new BasicNameValuePair(Const.TITLE, wordDetailVo.getTitle()));
		}
		
		return paramsArray;
	}
	
		
	/*public static String getLoginParams(String userId) {	// 로그인 파라메터
		String replaceString = userId.replace(" ", "%20");
		String params = "";
		
		params = isNull(params) ? (params = "?") : (params += "&");
		params += Const.PARAM_TARGET + "=" + Const.REQ001;
		
		if(!isNull(userId)) {
			params = isNull(params) ? (params = "?") : (params += "&");
			params += Const.USERID + "=" + replaceString;
		}
		
		return params;
	}*/
	
	/*public static ArrayList<NameValuePair> getPostDisinfection(HashMap<String, String> searchMap) {	// 소독대기  파라메터
		ArrayList<NameValuePair> paramsArray = new ArrayList<NameValuePair>();
		paramsArray.add(new BasicNameValuePair(Const.PARAM_TARGET, Const.REQ014));
		
		if(!isNull(searchMap.get("offCd").toString())) {
			paramsArray.add(new BasicNameValuePair(Const.SEARCHOFFCD, searchMap.get("offCd").toString()));
		}
		
		if(!isNull(searchMap.get("recNo").toString())) {
			paramsArray.add(new BasicNameValuePair(Const.SEARCHRECNO, searchMap.get("recNo").toString()));
		}
		
		if(!isNull(searchMap.get("sDate").toString())) {
			paramsArray.add(new BasicNameValuePair(Const.SEARCHSDATE, searchMap.get("sDate").toString()));
		}
		
		if(!isNull(searchMap.get("eDate").toString())) {
			paramsArray.add(new BasicNameValuePair(Const.SEARCHEDATE, searchMap.get("eDate").toString()));
		}
		
		if(!isNull(searchMap.get("userSn").toString())) {
			paramsArray.add(new BasicNameValuePair(Const.SEARCHUSERSN, searchMap.get("userSn").toString()));
		}
		
		if(!isNull(searchMap.get("cprNm").toString())) {
			paramsArray.add(new BasicNameValuePair(Const.SEARCHCPRNM, searchMap.get("cprNm").toString()));
		}
		
		if(!isNull(searchMap.get("targetPage").toString())) {
			paramsArray.add(new BasicNameValuePair(Const.TARGETPAGE, searchMap.get("targetPage").toString()));
		}
		return paramsArray;
	}*/
}
